home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / basic / dialogic.zip / EXAMPLE2.BAS < prev    next >
BASIC Source File  |  1990-01-31  |  5KB  |  119 lines

  1.  
  2. '┌───────────────────────────────────────────────────────┐
  3. '│ Written by Jonathan S. Waldman                        │
  4. '│ (C) 1989, 1990 Jonathan S. Waldman & Dialog Software  │
  5. '│ (C) Crescent Software.                                │
  6. '│ All rights reserved.                                  │
  7. '└───────────────────────────────────────────────────────┘
  8.  
  9. '============
  10. 'DiaLogic
  11. 'EXAMPLE2.BAS
  12. '============
  13.  
  14. '$INCLUDE: 'DIALOGIC.BI'         'include our DiaLogic TYPE definitions
  15.  
  16. '====================
  17. 'Initialize the mouse
  18. '====================
  19.  
  20.    CALL InitMouse(There%)        'see if mouse and driver are there
  21.    IF There% THEN                'if yes then
  22.       CALL ShowCursor            'show the mouse
  23.       CALL TextCursor(0, 4)      'use this to insure mouse is always visible
  24.    END IF
  25.  
  26. '======
  27. 'Set-up
  28. '======
  29.  
  30.    CALL HideCursor               'hide the mouse cursor during CLS & PRINTs
  31.    WIDTH , 25                    'insure we're in 25-line mode
  32.    COLOR 15, 1
  33.    CLS                           'clear the screen
  34.  
  35. '========================
  36. 'REDIM the arrays for now
  37. '========================
  38.  
  39.    '$DYNAMIC                     'make all arrays dynamic
  40.    MaxDBE = 20                   'use for our dimension statements
  41.                                  '  20 dialog box elements will be our max
  42.    REDIM SHARED DB(2, MaxDBE) AS DialogType  'REDIM these TYPE arrays
  43.    REDIM SHARED LB(0) AS DialogText          '  dynamically
  44.  
  45. '=======================================
  46. 'Define some convenient string variables
  47. '=======================================
  48.    PRINT
  49.    PRINT "   This is an example of a multi-tasking dialog box."
  50.    PRINT ""
  51.    PRINT "   Observe that the time is updated.  Also, try selecting <Help>, which"
  52.    PRINT "   is inactive, or try selecting <OK>, which will set all dialog box"
  53.    PRINT "   elements to specific values.  These examples demonstrate that multi-"
  54.    PRINT "   tasking dialog boxes can both inactivate and update their dialog box"
  55.    PRINT "   elements."
  56.  
  57.    CALL ShowCursor               'show it again
  58.  
  59.    Cancel$ = CHR$(27)            'these are our string assignments, also used
  60.    Help$ = CHR$(0) + CHR$(59)    '  in the FIND.DB template.
  61.    OK$ = CHR$(13)
  62.  
  63.    REDIM SHARED DB(2, MaxDBE) AS DialogType  'REDIM these TYPE arrays
  64.    REDIM SHARED LB(10) AS DialogText
  65.    Level% = 1                    'set Level% to 1
  66.    '$INCLUDE: 'FIND.DB'          'include Help dialog box template
  67.  
  68.    NotAvailable = 113
  69.    DB(Level%, 11).PrimaryColor = NotAvailable
  70.    DB(Level%, 11).WindowColor = NotAvailable
  71.    DB(Level%, 11).WindowColor = NotAvailable
  72.    DB(Level%, 11).KeyColor = NotAvailable
  73.  
  74.    Action% = 1                   'set Action% to 1
  75.    Focus% = 0                    'set the input focus to auto -- 0
  76.    CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  77.    Action% = 3                   'set Action to 3 for polling
  78.    ExitLoop = 0                  'set ExitLoop flag to false
  79.    DO
  80.       DO
  81.          IF Count% = 75 OR TIMER - OldTime! > .5 THEN 'update time every
  82.             OldTime! = TIMER                          '1/2 second or every
  83.             LOCATE 19, 13, 0                          'time count reaches
  84.             COLOR 1, 7                                '75
  85.             PRINT TIME$;
  86.             Count% = 0
  87.          END IF
  88.          CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  89.          Count% = Count% + 1
  90.       LOOP UNTIL Action% = 4              'wait until a key is pressed
  91.       SELECT CASE Ky$                     'examine command buttons or key
  92.          CASE Cancel$                     '<Cancel> was pushed
  93.             Action% = 5                   'remove the dialog box
  94.             CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  95.             ExitLoop = -1                 'get out
  96.          CASE Help$                       'ignore it but play a beep first
  97.             PLAY "L64<EC>"
  98.          CASE OK$
  99.             DB(Level%, 2).TextString = "Ok was pressed"  'set dialog box
  100.             DB(Level%, 3).Default = -1                   'options to show
  101.             DB(Level%, 4).Default = -1                   'on-the-fly
  102.             DB(Level%, 5).Default = 2                    'modification
  103.             Action% = 2                      'Action 2 refreshes DBEs
  104.             CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  105.             Action% = 3                      'resume polling in the DO loop              
  106.          CASE ELSE
  107.       END SELECT
  108.    LOOP UNTIL ExitLoop                    'exit when flag is set
  109.    COLOR 7, 0
  110.    CALL HideCursor
  111.    CLS
  112.    END
  113.  
  114. CloseBox:
  115.    Action% = 5                            'subroutine to remove a dialog box
  116.    CALL DiaLogic(DB(), LB(), Action%, Focus%, Ky$)
  117.    RETURN
  118.  
  119.